cmake_minimum_required (VERSION 3.10)

PROJECT(demo00)


## 可选配置
option( MODULE_BUILD_TESTS "Build tests" OFF )

## 依赖, 第三方库

#FIND_PACKAGE(fmt REQUIRED)


## 使用UTF-8编码，
ADD_COMPILE_OPTIONS("$<$<C_COMPILER_ID:MSVC>:/utf-8>")
ADD_COMPILE_OPTIONS("$<$<CXX_COMPILER_ID:MSVC>:/utf-8>")

if(ANDROID)
	# 设置去除未使用代码的链接flag
	# 可以手动的在链接选项中加入 strip参数
	SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Os -Wall -s -ffunction-sections -fdata-sections")
	SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Os -Wall -s -ffunction-sections -fdata-sections")
endif(ANDROID)


## 头文件目录
INCLUDE_DIRECTORIES( 
	./
)


## 源文件
SET(PRJ_SOURCE_FILES
	demo00.cpp
)


SOURCE_GROUP(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${PRJ_SOURCE_FILES})


SET( YATE_MODULE_TARGET demo00)  ## ${YATE_MODULE_TARGET}

ADD_LIBRARY( ${YATE_MODULE_TARGET} SHARED
	${PRJ_SOURCE_FILES}
)

# TARGET_INCLUDE_DIRECTORIES( ${YATE_MODULE_TARGET} PRIVATE  xxx )

## 链接Yate库
TARGET_LINK_LIBRARIES( ${YATE_MODULE_TARGET} 
	${yate_engine_lib} 
	# fmt::fmt-header-only 
)

SET_PROPERTY(TARGET ${YATE_MODULE_TARGET} PROPERTY FOLDER "modules-demo")

## 设置插件的后缀为.yate 
SET_TARGET_PROPERTIES(${YATE_MODULE_TARGET} PROPERTIES SUFFIX ".yate")

SET_TARGET_PROPERTIES(${YATE_MODULE_TARGET} PROPERTIES PREFIX "")

INSTALL (TARGETS ${YATE_MODULE_TARGET} LIBRARY DESTINATION modules )


if( MODULE_BUILD_TESTS )
	ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/test )
endif(MODULE_BUILD_TESTS)

## 安装conf.d目录下文件
INSTALL(DIRECTORY conf.d 
	DESTINATION .
	PATTERN "CVS" EXCLUDE
    PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ
)
